<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      .box {
        width: 200px;
        height: 200px;
        border: 1px solid red;
      }
      .red {
        background: red;
      }
      .blue {
        background: blue;
      }
      .green {
        background: green;
      }
    </style>
  </head>
  <body>
    <div id="app">
      <button @click="aa='red'">红色</button>
      <button @click="aa='blue'">蓝色</button>
      <button @click="aa='green'">绿色</button>
      <div class="box" :style="{background:aa}"></div>
      <div :class="['box',aa]"></div>
    </div>
    <script src="vue-2.4.0.js"></script>
    <script>
      var vm = new Vue({
        el: "#app",
        data: {
          aa: "red",
        },
      });
    </script>
  </body>
</html>
